#ifndef __UTIL__MATERIALS_HPP__
#define __UTIL__MATERIALS_HPP__

#include <string>
#include <QGLWidget>

namespace util {
  /** @brief A utility class for materials.

      @todo Clean up the indexing with constrained_value

      This class provides an interface for VLAB material files and
      their use for OpenGL.  The material files can contain upto 255
      materials.  The class allows access to these by an index.  If a
      material index is called that is not in the file, a default
      material is provided that uses the default values for OpenGL
      1.2.
  */

  class materials {
  public:
    /** @brief The material data structure. */
    struct material {
      GLfloat ambient[4];
      GLfloat diffuse[4];
      GLfloat emission[4];
      GLfloat specular[4];
      GLfloat shiny;
      GLfloat transparency;
    };

    materials(std::string filename);

    void reread();

    void            use(unsigned int index);
    const material& get(unsigned int index);
    void            blend(unsigned int ind1, unsigned int ind2, float t);

  private:
    std::string filename;
    material    mats[256];
  };
}

#endif
